package cn.com.api.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.com.api.entity.ApiT_user_cash_records;
import cn.com.api.service.ApiT_user_cash_recordsService;
import cn.com.api.service.CheckService;
import cn.com.pingpp.PingppUtil;
import cn.com.util.*;

@Controller
@RequestMapping(Utils.SYS_API + "t_user_cash_records/")
public class ApiT_user_cash_recordsController {
	@Autowired
	private ApiT_user_cash_recordsService apiT_user_cash_recordsService;
	@Autowired
	private CheckService checkService;

	private static Logger logger = Logger.getLogger(ApiT_user_cash_recordsController.class);

	/**
	 * @Title: 获取用户金额明细
	 * @return void
	 */
	@RequestMapping(value = "getUserCashRecords")
	public void getUserCashRecords(HttpServletRequest request, HttpServletResponse response, String user_id,
			String token, String date) {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			Map<String, String> paramMap = new HashMap<String, String>();
			paramMap.put("u_id", user_id);
			paramMap.put("token", token);
			if (checkService.checkToken(user_id, token, map) && checkService.checkParams(paramMap, map)) {
				map.clear();
				List<ApiT_user_cash_records> list = apiT_user_cash_recordsService.getUserCashRecords(user_id, date);
				map.put(Utils.RESULT, Utils.RESULT_RC_SUCCESS);
				map.put(Utils.MESSAGE, "操作成功");
				map.put(Utils.DATAS, list);
			}
		} catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			map.put(Utils.RESULT, Utils.RESULT_RC_CHECK_FAIL);
			map.put(Utils.MESSAGE, "系统异常！");
		}
		JsonUtil.printJson(response, JsonUtil.object2json(map));
	}
}
